package com.example.bili.view.fragment;

import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;


import com.example.bili.R;
import com.example.bili.adapter.PartitionAdapter;
import com.example.bili.allbean.PartitionBean;
import com.example.bili.base.BaseFragment;
import com.example.bili.view.activity.AdvertiActivity;
import com.example.bili.view.activity.AnimationActivity;
import com.example.bili.view.activity.DanceActivity;
import com.example.bili.view.activity.FanJuActivity;
import com.example.bili.view.activity.FashionActivity;
import com.example.bili.view.activity.GameActivity;
import com.example.bili.view.activity.GamecenterActivity;
import com.example.bili.view.activity.GuichuActivity;
import com.example.bili.view.activity.LifeActivity;
import com.example.bili.view.activity.LiveActivity;
import com.example.bili.view.activity.MovieActivity;
import com.example.bili.view.activity.MusicActivity;
import com.example.bili.view.activity.RecreationActivity;
import com.example.bili.view.activity.ScienceActivity;
import com.example.bili.view.activity.TeleplayActivity;

import java.util.ArrayList;
import java.util.List;


/**
 * Created by Administrator on 2017/3/9. 分区
 */

public class partitionpage extends BaseFragment {

    private GridView l_partition_gv;
    private String[] fenqu={"直播","番剧","动画","音乐","舞蹈","游戏","科技","生活","鬼畜","时尚","广告","娱乐","电影",
            "电视剧","游戏中心"};
   private List<PartitionBean> list=new ArrayList<>();
   public void initview(View view) {
      PartitionAdapter partitionAdapter=new PartitionAdapter(getContext(),R.layout.partition_item,list);
       l_partition_gv = (GridView) view.findViewById(R.id.l_partition_gv);
       l_partition_gv.setAdapter(partitionAdapter);
      partitionAdapter.clear();
      initPartition();

      l_partition_gv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
              switch (position){
                  case 0:
                      Intent intent=new Intent(getContext(), LiveActivity.class);
                      startActivity(intent);
                      break;
                  case 1:
                      Intent intent1=new Intent(getContext(), FanJuActivity.class);
                      startActivity(intent1);
                      break;
                  case 2:
                      Intent intent2=new Intent(getContext(), AnimationActivity.class);
                      startActivity(intent2);
                      break;
                  case 3:
                      Intent intent3=new Intent(getContext(), MusicActivity.class);
                      startActivity(intent3);
                      break;
                  case 4:
                      Intent intent4=new Intent(getContext(), DanceActivity.class);
                      startActivity(intent4);
                      break;
                  case 5:
                      Intent intent5=new Intent(getContext(), GameActivity.class);
                      startActivity(intent5);
                      break;
                  case 6:
                      Intent intent6=new Intent(getContext(), ScienceActivity.class);
                      startActivity(intent6);
                      break;
                  case 7:
                      Intent intent7=new Intent(getContext(),LifeActivity.class);
                      startActivity(intent7);
                      break;
                  case 8:
                      Intent intent8=new Intent(getContext(), GuichuActivity.class);
                      startActivity(intent8);
                      break;
                  case 9:
                      Intent intent9=new Intent(getContext(), FashionActivity.class);
                      startActivity(intent9);
                      break;
                  case 10:
                      Intent intent10=new Intent(getContext(),AdvertiActivity.class);
                      startActivity(intent10);
                      break;
                  case 11:
                      Intent intent11=new Intent(getContext(), RecreationActivity.class);
                      startActivity(intent11);
                      break;
                  case 12:
                      Intent intent12=new Intent(getContext(), MovieActivity.class);
                      startActivity(intent12);
                      break;
                  case 13:
                      Intent intent13=new Intent(getContext(), TeleplayActivity.class);
                      startActivity(intent13);
                      break;
                  case 14:
                      Intent intent14=new Intent(getContext(), GamecenterActivity.class);
                      startActivity(intent14);
                      break;

              }

          }
      });
    }

    private void initPartition() {

        PartitionBean live=new PartitionBean("直播",R.drawable.ic_category_live);
        list.add(live);
        PartitionBean fanju=new PartitionBean("番剧",R.drawable.ic_category_t13);
        list.add(fanju);
        PartitionBean animator=new PartitionBean("动画",R.drawable.ic_category_t1);
        list.add(animator);
        PartitionBean music=new PartitionBean("音乐",R.drawable.ic_category_t3);
        list.add(music);
        PartitionBean dance=new PartitionBean("舞蹈",R.drawable.ic_category_t129);
        list.add(dance);
        PartitionBean game=new PartitionBean("游戏",R.drawable.ic_category_t4);
        list.add(game);
        PartitionBean science=new PartitionBean("科技",R.drawable.ic_category_t36);
        list.add(science);
        PartitionBean life=new PartitionBean("生活",R.drawable.ic_category_t160);
        list.add(life);
        PartitionBean guichu=new PartitionBean("鬼畜",R.drawable.ic_category_t119);
        list.add(guichu);
        PartitionBean fashion=new PartitionBean("时尚",R.drawable.ic_category_t155);
        list.add(fashion);
        PartitionBean adverti=new PartitionBean("广告",R.drawable.ic_category_t165);
        list.add(adverti);
        PartitionBean recreation=new PartitionBean("娱乐",R.drawable.ic_category_t5);
        list.add(recreation);
        PartitionBean movie=new PartitionBean("电影",R.drawable.ic_category_t23);
        list.add(movie);
        PartitionBean teleplay=new PartitionBean("电视剧",R.drawable.ic_category_t11);
        list.add(teleplay);
        PartitionBean gamecenter=new PartitionBean("游戏中心",R.drawable.ic_category_game_center);
        list.add(gamecenter);
    }

    @Override
    protected void m_onCreateView() {

    }

    @Override
    public View getLayoutview() {
        return View.inflate(getActivity(), R.layout.partitionpage, null);

    }



}
